#include <bits/stdc++.h>

using namespace std;

class Solution {
	public:
		int numberOfWeakCharacters(vector<vector<int>>& properties)
		{
			sort(begin(properties), end(properties));
			// for (auto& vec : properties) printf("(%d,%d)\t", vec[0], vec[1]); putchar('\n');
			auto be = rbegin(properties), en = rend(properties);
			auto [vis, max] = (int(&)[2])(*be)[0];
			int res = 0, temp = max;
			for (; be != en; ++be) if ((*be)[0] != vis) break;
			for (; be != en; ++be) {
				auto [cvis, cval] = (int(&)[2])(*be)[0];
				if (vis != cvis) {
					vis = cvis;
					max = temp;
					temp = ::max(cval, temp);
				}
				if (max > cval) { res++; printf("(%d,%d)\t", cvis, cval); }
			}
			return res;
		}

	private:
};

int main()
{
	[[maybe_unused]] Solution solution;
	return 0;
}
